import 'package:flutter/material.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:moose_app/ui/values/constants.dart';

class ATHStickyTabBarDelegate extends SliverPersistentHeaderDelegate {
  final TabBar child;

  final bool showMore;

  final Function onMorePress;

  ATHStickyTabBarDelegate(
      {@required this.child, this.showMore = false, this.onMorePress});

  @override
  Widget build(
      BuildContext context, double shrinkOffset, bool overlapsContent) {
    return Container(
      color: Colors.white,
      child: Row(
        children: <Widget>[
          Expanded(
            child: this.child,
          ),
          showMore
              ? GestureDetector(
                  onTap: onMorePress,
                  child: Container(
                    width: kSize80,
                    child: SvgPicture.asset(
                      'assets/icons/icon_more_menu.svg',
                      width: kSize32,
                    ),
                  ),
                )
              : SizedBox()
        ],
      ),
    );
  }

  @override
  double get maxExtent => this.child.preferredSize.height;

  @override
  double get minExtent => this.child.preferredSize.height;

  @override
  bool shouldRebuild(SliverPersistentHeaderDelegate delegate) {
    return true;
  }
}
